package main

import (
	httptransport "github.com/go-kit/kit/transport/http"
	"log"
	"net/http"
)

func main() {
	svc := stringService{}

	uppercaseHandler := httptransport.NewServer(
		makeUppercaseEndpoint(svc),
		decodeUppercaseRequest,
		encodeResponse,
	)

	countHandler := httptransport.NewServer(
		makeCountEndpoint(svc),
		decodeCountRequest,
		encodeResponse,
	)
	countHandler.Name = "count"
	countHandler.Methods = []string{"GET"}
	countHandler.Path = "/count"
	countHandler.AllowedMethods = []string{"GET"}
	countHandler.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {if r.Method != "GET" {
			w.WriteHeader(http.StatusMethodNotAllowed)
			return
		}
		countHandler.ServeHTTP(w, r)
	

	http.Handle("/", http.FileServer(http.Dir("./static")))
	http.Handle("/uppercase", uppercaseHandler)
	http.Handle("/count", countHandler)
	log.Fatal(http.ListenAndServe(":9090", nil))
}
